<?php echo '<?xml version="1.0" encoding="UTF-8"?>' ?>
<rss version="0.92">
<channel>
	<title><?php echo APPLICATION_TITLE, (isset($category) ? ' &#187; '.$category->category_name : ''); ?></title>
	<link>http://www.findopendeals.com</link>
	<description>Find Open Deals</description>
	<lastBuildDate><?php echo date("D, d M Y H:i:s T");?></lastBuildDate>
	<docs>http://backend.userland.com/rss092</docs>
	<language>en</language>	
	<?php 	if (isset($products) && $products->num_rows() > 0) 
			{
				foreach ($products->result() as $row)
				{
					$rss_publish_date = new DateTime($row->rss_publish_date);  
					$product_link = get_product_url($row);
					$first_paragraph_end = strpos($row->product_desc, "</p>"); 
					$first_paragraph_end = $first_paragraph_end > 1000 ? 1000 : $first_paragraph_end;
					$first_paragraph_end = $first_paragraph_end == 0 ? 1000 : $first_paragraph_end;
					echo '<item>';
					echo "\r\n";
					echo '<title><![CDATA[',dataCleasing(utf8_encode($row->product_title)),']]></title>';
					echo "\r\n";
					echo '<description><![CDATA[', dataCleasing(utf8_encode(strip_tags(substr($row->product_desc, 0, $first_paragraph_end)))),']]></description>';
					echo "\r\n";
					echo '<link>',($product_link),'</link>';
					echo "\r\n";
					//echo '<pubDate>',date_format($rss_publish_date, "D, d M Y H:i:s T"),'</pubDate>';
					echo '<pubDate>',date("D, d M Y H:i:s T"),'</pubDate>';
					echo "\r\n";
					echo '</item>';
					echo "\r\n";
				}
			}
	?>
</channel>
</rss>
